package microcredit.gui;

import java.awt.Color;
import java.awt.Font;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.Insets;

import javax.swing.ImageIcon;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JProgressBar;
import javax.swing.border.EtchedBorder;

public class LoadingFrame extends JFrame {

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	private JPanel contentPane;
	private JLabel label;
	private JLabel lblMicrocreditIsLoading;
	private JProgressBar progressBar;

	/**
	 * Create the frame.
	 */
	public LoadingFrame() {
		setUndecorated(true);
		setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		setBounds(100, 100, 280, 90);
		contentPane = new JPanel();
		GridBagLayout gridBagLayout = new GridBagLayout();
		gridBagLayout.columnWidths = new int[]{0, 0, 0};
		gridBagLayout.rowHeights = new int[]{0, 0, 0};
		gridBagLayout.columnWeights = new double[]{0.0, 1.0, 1.0E-4};
		gridBagLayout.rowWeights = new double[]{1.0, 1.0, 1.0E-4};
		contentPane.setLayout(gridBagLayout);
		contentPane.setBorder(new EtchedBorder(EtchedBorder.LOWERED, null, null));
		setContentPane(contentPane);
		GridBagConstraints gbc = new GridBagConstraints();
		gbc.gridheight = 2;
		gbc.insets = new Insets(0, 10, 0, 5);
		gbc.gridx = 0;
		gbc.gridy = 0;
		contentPane.add(getLabel(), gbc);
		GridBagConstraints gbc_1 = new GridBagConstraints();
		gbc_1.insets = new Insets(0, 0, 5, 0);
		gbc_1.anchor = GridBagConstraints.SOUTHWEST;
		gbc_1.gridx = 1;
		gbc_1.gridy = 0;
		contentPane.add(getLblMicrocreditIsLoading(), gbc_1);
		GridBagConstraints gbc_2 = new GridBagConstraints();
		gbc_2.insets = new Insets(0, 0, 0, 15);
		gbc_2.anchor = GridBagConstraints.NORTH;
		gbc_2.fill = GridBagConstraints.HORIZONTAL;
		gbc_2.gridx = 1;
		gbc_2.gridy = 1;
		contentPane.add(getProgressBar(), gbc_2);
	}

	public void setProgress(int progress) {
		
	}
	
	private JLabel getLabel() {
		if (label == null) {
			label = new JLabel("");
			label.setIcon(new ImageIcon(LoadingFrame.class.getResource("/microcredit/icons/x48/environment_add.png")));
			label.setName("label");
		}
		return label;
	}
	private JLabel getLblMicrocreditIsLoading() {
		if (lblMicrocreditIsLoading == null) {
			lblMicrocreditIsLoading = new JLabel("MicroCredit is loading...");
			lblMicrocreditIsLoading.setFont(lblMicrocreditIsLoading.getFont().deriveFont(lblMicrocreditIsLoading.getFont().getStyle() | Font.BOLD, 16f));
			lblMicrocreditIsLoading.setName("lblMicrocreditIsLoading");
			lblMicrocreditIsLoading.setName("label_1");
		}
		return lblMicrocreditIsLoading;
	}
	private JProgressBar getProgressBar() {
		if (progressBar == null) {
			progressBar = new JProgressBar();
			progressBar.setForeground(new Color(144, 238, 144));
			progressBar.setIndeterminate(true);
			progressBar.setName("progressBar");
		}
		return progressBar;
	}
}
